Skip to content

Conversation

@hnrklssn
Copy link
Member

A Swift module only imports a type definition once. This means that some clang modules may have function signatures imported with UnsafePointer<qux> even if qux is only forward declared in that module (which would normally be imported as OpaquePointer), because some Swift file in the module imported the clang module with the definition, so ClangImporter sees the definition. The macro expansion only imports the imports of the clang module it belongs to however, so namelookup for qux fails. This patch detects when this will result in an error and avoids attaching the macro in those cases.

rdar://165864358

A Swift module only imports a type definition once. This means that some
clang modules may have function signatures imported with
`UnsafePointer<qux>` even if `qux` is only forward declared in that
module (which would normally be imported as `OpaquePointer`), because
some Swift file in the module imported the clang module with the
definition, so ClangImporter sees the definition. The macro expansion
only imports the imports of the clang module it belongs to however, so
namelookup for `qux` fails. This patch detects when this will result in
an error and avoids attaching the macro in those cases.

rdar://165864358
@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

Implicit decls don't have an owning module, since multiple modules could
instantiate them on demand. Since no implicit functions currently have
any need for safe wrappers we can simply detect this and early exit. For
templated functions, we need to fetch the owning module from the
instantiation.
@hnrklssn
Copy link
Member Author

@swift-ci please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants